import { Component, OnInit, EventEmitter } from '@angular/core';

@Component({
  selector: 'app-sub',
  templateUrl: './sub.component.html',
  styleUrls: ['./sub.component.css'],
  inputs: ['mybody','abc'], // 父组件可以改变子组件的值
  outputs: ['myevent'] // 父组件可以绑定子组件定义的事件
})
export class SubComponent implements OnInit {

  constructor() { }
  ngOnInit() {
  }

  mybody = 'sub title';
  mydate = new Date('2018-09-27');
  switchOpt = "b";
  list = [
    {name: 'zhao1'},
    {name: 'zhao2'},
    {name: 'zhao3'}
  ];
  myevent = new EventEmitter(); // 自定义事件
  changetitle() {
    this.mybody += ' add click';
    this.myevent.emit(); //出发自定义事件
  }

}
